import { Service } from "cl-admin";
import BaseService from "@/service/base";
import { last } from "cl-admin/utils";

@Service("AfterSale")
class AfterSale extends BaseService {
	// 售后个人报表
	afterPersonreport({ date = [], bra_id = [], ...args }) {
		let params = {
			...args,
			bra_id: bra_id.join()

		};
		if (date.length) {
			params.start_time = date[0];
			params.end_time = date[1];
		};
		return this.$get("/dayreport", { params });
	}
	//预约流失上报取消
	vindicatecancel(params) {
		return this.$post("/vindicatecancel", params);
	}
	//部门报表-1
	getDeptperson({ date = [], dept_ids, bra_id = [], ...args }) {
		let params = {
			...args,
			dept_id: dept_ids.join(),
			bra_id: bra_id.join()
		};
		if (date.length) {
			params.start_time = date[0];
			params.end_time = date[1];
		};
		// if (dept_ids.length) {
		//     params.dept_id = last(dept_ids);
		// } else {
		//     params.dept_id = "";
		// }
		return this.$get("/reportdept", { params })
	}

	//部门报表-门店报表
	getReportshop({ date = [], bra_id = [], ...args }) {
		let params = {
			...args,
			bra_id: bra_id.join()
		};
		if (date.length) {
			params.start_time = date[0];
			params.end_time = date[1];
		};
		return this.$get("/reportshop", { params });
	}

	// 预约流失 提交记录
	async cartOrdering({ appointTime = [], subAppoint = [], bra_id = [], ...args }) {
		let params = { ...args }
		if (appointTime && appointTime.length) {
			// params.appoint_begin_time = args.is_undetermined == 1 ? appointTime[0] : ''
			// params.appoint_end_time = args.is_undetermined == 1 ? appointTime[1] : ''
			params.appoint_begin_time = appointTime[0] || ''
			params.appoint_end_time = appointTime[1] || ''
		}
		if (subAppoint && subAppoint.length) {
			params.create_begin_time = subAppoint[0]
			params.create_end_time = subAppoint[1]
		}
		if (bra_id.length) {
			params.bra_id = bra_id.join()
		}
		return this.$get("/cartordering", { params }).then(res => {
			return {
				list: res?.data ?? [],
				pagination: {
					...params,
					total: res?.total ?? 0
				}
			};
		})
	}

	// 公众号投诉与建议-列表
	async complList({ time = [], ...args }) {
		let params = { ...args }
		if (time && time.length) {
			params.start_time = time[0]
			params.end_time = time[1]

		}
		return this.$get("/compllist", { params }).then(res => {
			return {
				list: res.data ?? [],
				pagination: {
					...params,
					total: res?.total ?? 0
				}
			};
		})
	}


	// 公众号投诉与建议-审核
	complcCheck(params) {
		return this.$post("/complcheck", params);
	}

	// 公众号投诉与建议-详情
	complchecklog(params) {
		return this.$get("/complchecklog", { params });
	}


	orderingCheck(params) {
		return this.$post("/cartorderingcheck", params);
	}
	cartLose(params) {
		return this.$post("/cartLose", params);
	}
	// 预约流失详情
	getLost(params) {
		return this.$get("/getLost", { params });
	}
	//修改流失跟进状态
	editFollowStatus(params) {
		return this.$post("/editFollowStatus", params);
	}
}

export default AfterSale;
